//
//  SettingView.swift
//  SnapKitTest
//
//  Created by jin on 2024/8/13.
//

import UIKit

class SettingView: UIView {
    
    init() {
        super.init(frame: CGRect.zero)
        innerInit()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        innerInit()
    }
    
    func innerInit(){
        backgroundColor = .white
        addSubview(leftImgView)
        addSubview(rightImgView)
        addSubview(titleView)
    }
    
    /// 当视图加入父视图时 / 当视图从父视图移除时调用
    override func didMoveToSuperview() {
        super.didMoveToSuperview()
        //添加约束
        leftImgView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.centerY.equalToSuperview()
            
            make.width.equalTo(20)
            make.height.equalTo(20)
        }
        
        titleView.snp.makeConstraints { make in
            make.left.equalTo(leftImgView.snp.right).offset(16)
            make.centerY.equalToSuperview()
        }
        
        rightImgView.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-16)
            make.centerY.equalToSuperview()
            
            make.width.equalTo(20)
            make.height.equalTo(20)
        }
    }

    ///左侧图标
    lazy var leftImgView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "Setting")
        return imageView
    }()
    
    ///右侧图标
    lazy var rightImgView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "Arrow")
        return imageView
    }()
    
    ///标题
    lazy var titleView: UILabel = {
        let textView = UILabel()
        textView.text = "标题"
        return textView
    }()
}
